package py.com.alfa.escriba.web.services.impl;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import py.com.alfa.escriba.exception.ServiceException;
import py.com.alfa.escriba.persistence.dao.PersonasDAO;
import py.com.alfa.escriba.persistence.dao.PersonasjuridicasinfoDAO;
import py.com.alfa.escriba.persistence.dto.admin.PersonaDTO;
import py.com.alfa.escriba.web.services.PersonasService;

@Transactional(readOnly = true)
public class PersonasServiceImpl implements PersonasService{
	
	private PersonasDAO personasDAO;
	private PersonasjuridicasinfoDAO personasJuridicasInfoDAO;
	
	public PersonasServiceImpl() {}


	public PersonasDAO getPersonasDAO() {
		return personasDAO;
	}


	public void setPersonasDAO(PersonasDAO personasDAO) {
		this.personasDAO = personasDAO;
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor=ServiceException.class)
	public PersonaDTO obtenerPersona(Long id) throws ServiceException {
		PersonaDTO dto = this.personasDAO.obtenerPersona(id);		
		return dto;
	}


	@Override
	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor=ServiceException.class)
	public PersonaDTO crearPersona(PersonaDTO dto) throws ServiceException {
		this.personasDAO.crearPersona(dto);	
		PersonaDTO result = this.personasDAO.obtenerPersona(dto.getId());
		return result;
	}


	public PersonasjuridicasinfoDAO getPersonasJuridicasInfoDAO() {
		return personasJuridicasInfoDAO;
	}


	public void setPersonasJuridicasInfoDAO(PersonasjuridicasinfoDAO personasJuridicasInfoDAO) {
		this.personasJuridicasInfoDAO = personasJuridicasInfoDAO;
	}

}
